package com.info33.platform.doc.controller;

import com.info33.platform.common.mvc.controller.BaseController;
import com.info33.platform.common.mvc.vo.Result;
import com.info33.platform.doc.dto.DocFileDownloadDTO;
import com.info33.platform.doc.entity.DocFileDetail;
import com.info33.platform.doc.service.DocFileDetailService;
import com.info33.platform.doc.vo.DocFileDetailVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author admin
 */
@RestController
@RequestMapping("/DocFileDetail")
@Api(tags = "文档管理 - 文件明细")
public class DocFileDetailController extends BaseController<DocFileDetailService, DocFileDetail> {

    private final DocFileDetailService docFileDetailService;

    @Autowired
    public DocFileDetailController(DocFileDetailService docFileDetailService) {
        super(docFileDetailService);
        this.docFileDetailService = docFileDetailService;
    }

    @PostMapping(value = "/listFile")
    @ApiOperation(value = "获取列表")
    public Result<List<DocFileDetailVO>> listFile(@RequestBody DocFileDetail docFileDetail) {
        return Result.ok(docFileDetailService.listFile(docFileDetail));
    }
    
    @PostMapping(value = "/removeFile")
    @ApiOperation(value = "批量删除")
    public Result<?> removeFile(@RequestBody List<Long> ids) {
        return docFileDetailService.removeFile(ids);
    }
    
    @PostMapping("/download")
    @ApiOperation(value = "下载")
    public Result<?> download(HttpServletResponse response, @RequestBody DocFileDownloadDTO docFileDownloadDTO) {
    	return docFileDetailService.download(response, docFileDownloadDTO, getCurrentUser());
    }


}